package com.gscitysfy.cus.drain.modules.warning.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gscitysfy.cloudfrmwk.assistant.domain.Result;
import com.gscitysfy.cus.drain.modules.warning.entity.DrainSignal;
import com.gscitysfy.cus.drain.modules.warning.service.IDrainSignalService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author user
 * @since 2022-10-22 15:33:42
 */
@RestController
@RequestMapping("/warning/drainSignal")
public class DrainSignalController {
    @Autowired
    IDrainSignalService drainSignalService;

    /**
     * 获取预警机制列表
     * @return
     */
    @Operation(summary = "获取预警机制列表")
    @GetMapping("/page")
    public Result<Object> page(@Parameter(hidden = true) Page<DrainSignal> page, @Parameter(hidden = true) DrainSignal drainSignal){
        return drainSignalService.getByPage(page, drainSignal);
    }

    @Operation(summary = "获取预警机制灾害预报类型")
    @GetMapping("/getWarningSignalTypeList")
    public Result<List<String>> getWarningSignalTypeList(){
        return Result.content(drainSignalService.getWarningSignalTypeList());
    }

    @Operation(summary = "获取预警机制灾害等级")
    @GetMapping("/getWarningSignalLevel")
    public Result<List<String>> getWarningSignalLevel(){
        return Result.content(drainSignalService.getWarningSignalLevel());
    }


    /**
     * 修改或者保存预警机制
     * @param drainSignal
     * @return
     */
    @PostMapping("/save")
    @Operation(summary = "修改或者保存预警机制")
    public Result<Boolean> addOrUpdate(@Parameter(hidden = true)@RequestBody DrainSignal drainSignal ){
        return  Result.content(drainSignalService.saveOrUpdate(drainSignal));
    }



}
